Skip to content

fix: coerce callable AgentInfo.instruction for app-info - #6913

Closed
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/app-info-callable-instruction
Closed

fix: coerce callable AgentInfo.instruction for app-info#6913
a2105z wants to merge 1 commit into
google:mainfrom
a2105z:fix/app-info-callable-instruction

Conversation

@a2105z

@a2105z a2105z commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GET /apps/{app_name}/app-info built AgentInfo with instruction=current_agent.instruction. That field is typed str, but LlmAgent.instruction is str | InstructionProvider. A callable raised an unhandled pydantic.ValidationError (500).
  • Coerce callables to a readable placeholder (<InstructionProvider: {name}>) in a before validator. Do not resolve the provider: it may be async and may need session state.
  • String instructions are unchanged. Class-based providers (no __name__) use the type name.

Fixes #6909

Test plan

  • Reproduced: get_agents_dict on an agent with instruction=dynamic_instruction raises ValidationError: Input should be a valid string (input_type=function) at agent_info.py _traverse / AgentInfo(...).
  • After the fix, uv run pytest tests/unittests/utils/test_agent_info.py13 passed
    • named function → <InstructionProvider: dynamic_instruction> (provider is not invoked)
    • async provider + callable on a sub-agent
    • callable instance → <InstructionProvider: Persona>
    • plain string instruction still round-trips
  • CLA check

@itaieban this is done — app-info now serializes callable instructions instead of 500ing.

Made with Cursor

GET /apps/{app_name}/app-info assigned LlmAgent.instruction onto
AgentInfo.instruction (typed str). InstructionProvider callables
raised ValidationError. Coerce to a placeholder; do not resolve
providers (they can be async and need session state).

Fixes google#6909
@adk-bot

adk-bot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Thank you @a2105z for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit ada8652.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Aug 31, 2026
@adk-bot adk-bot closed this Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/apps/{app_name}/app-info returns 500 when an agent's instruction is an InstructionProvider (callable) instead of a str

3 participants